package responsibilitychain;

/**
 * @author chenyuan
 * @date 2020/10/30 16:58
 */

/**
 * 如果其他处理者都处理不了就让这个来处理
 */
public class FailureApprover extends Approver{
    public FailureApprover(String name) {
        super(name);
    }

    @Override
    public void processRequest(PurchaseRequest purchaseRequest) {
        if (purchaseRequest.getPrice() <= 0){
            // 满足要求改处理者处理
            System.out.println("== 请求编号 id = "+purchaseRequest.getId()
                    +"的金额小于等于 0 ，处理失败");
        }else{// 不满足要求传递给下一个
            approver.processRequest(purchaseRequest);
        }
    }
}
